package com.league.zjxn.main.adapter

import android.view.View
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.league.zjxn.R
import com.league.zjxn.entity.Message

class MessageAdapter : BaseQuickAdapter<Message, BaseViewHolder>(R.layout.item_message_list) {
    override fun convert(holder: BaseViewHolder, item: Message) {
        //类型【1=关注企业,2=关注项目,3=加盟申请,4=项目意向申请】
        holder.setText(
            R.id.tvMessageListName, when (item.type) {
                "1" -> "联盟企业消息"
                "2" -> "策划项目消息"
                "3" -> "加盟申请消息"
                "4" -> "项目意向申请消息"
                else -> "其它消息"
            }
        )
            .setText(R.id.tvMessageListContent, item.message)
            .setText(R.id.tvMessageListTime, item.create_time)
            .getView<View>(R.id.vwMessageListView).apply {
                visibility = if (item.is_read == "0") View.VISIBLE else View.GONE
            }
    }
}